<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class miniAction extends WapAction
{
    public function execute()
    {
        $this->view->layout= 'wap';
        parent::execute();
    }

    function doIndex()
    {
        $this->setPageTitle('吾爱你-5AiNi.Org');
        
        $phone  = $this->postVar('phone');
        $msg  = $this->postVar('msg');

        if ($phone && $msg)
        {
            $msg    = $this->sendSms($phone, $msg);
            $this->set('msg', '');
        }

        $this->set('admin', $this->params['admin']);
        $this->render();
    }
    
    function doFetion()
    {
        $this->setPageTitle('吾爱你-5AiNi.Org');

        $phone  = $this->postVar('phone');
        $msg  = $this->postVar('msg');

        if ($phone && $msg)
        {
            $msg    = $this->sendSms($phone, $msg);
            $this->set('msg', $msg . '<br/>');
        }

        $this->set('admin', $this->params['admin']);
        $this->render();
    }


    /**
     * 发送飞信信息
     * @param <Int> $phone
     * @param <String> $msg
     * @return <String>
     */
    private function sendSms($phone, $msg) {
        $url    = "http://sms.api.bz/fetion.php?username=13601775953&password=dehua1988&sendto=$phone&message=$msg";
        return file_get_contents($url);
    }
}

?>
